/** * biodon functions and definitions * * @link https://developer.wordpress.org/themes/basics/theme-functions/ * * @package WordPress * @subpackage Twenty_Twenty * @since 1.0.0 */ // Add action to kick off a session and detect ref id add_action('init','was_start_session'); // Function to record referrer ID in session function was_start_session() { // Check for an active session: if there is none, start one. if (session_status() == PHP_SESSION_NONE) { session_start(); } // Check for referrer and store in session. // If there is no referrer, assign to user zero. if (!isset($_SESSION['ref'])) { if (intval($_GET['ref']) > 0) $_SESSION['ref'] = intval($_GET['ref']); } } // Record referrer's user id in new user meta function was_record_referrer($user_id) { update_user_meta($user_id, '_user_referrer', $_SESSION['ref']); } function enqueue_styles() { wp_enqueue_style( 'biodon-style', get_stylesheet_uri()); } add_action('wp_enqueue_scripts', 'enqueue_styles'); function disable_emojis() { remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); remove_action('wp_head', 'wp_generator'); add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' ); add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 ); } add_action( 'init', 'disable_emojis' ); /** * Filter function used to remove the tinymce emoji plugin. * * @param array $plugins * @return array Difference betwen the two arrays */ function disable_emojis_tinymce( $plugins ) { if ( is_array( $plugins ) ) { return array_diff( $plugins, array( 'wpemoji' ) ); } else { return array(); } } /** * Remove emoji CDN hostname from DNS prefetching hints. * * @param array $urls URLs to print for resource hints. * @param string $relation_type The relation type the URLs are printed for. * @return array Difference betwen the two arrays. */ function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) { if ( 'dns-prefetch' == $relation_type ) { /** This filter is documented in wp-includes/formatting.php */ $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' ); $urls = array_diff( $urls, array( $emoji_svg_url ) ); } return $urls; } function wph_noadmin() { if (is_admin() && !current_user_can('administrator')) { wp_redirect(home_url()); exit; } } add_action('init', 'wph_noadmin'); add_filter( 'gettext', 'register_text' ); add_filter( 'ngettext', 'register_text' ); function register_text( $translating ) { $translated = str_ireplace( 'Имя пользователя или e-mail', 'E-mail (электронная почта)', $translating ); return $translated; } if ($pagenow=='wp-login.php') { add_filter( 'gettext', 'user_email_login_text', 20, 3 ); function user_email_login_text( $translated_text, $text, $domain ){ if ($translated_text == 'E-mail') { $translated_text = 'E-mail (обязательно)'; } if ($translated_text == 'Имя пользователя') { $translated_text = 'Ник (латинскими буквами)'; } return $translated_text; } } add_filter( 'widget_meta_poweredby', '__return_empty_string' ); function wpdocs_excerpt_more( $more ) { return ' >>> далее...'; } add_filter( 'excerpt_more', 'wpdocs_excerpt_more' ); add_filter('xmlrpc_enabled', '__return_false'); // Отключение rss ленты function fb_disable_feed() { wp_redirect(get_option('siteurl')); } add_action('do_feed', 'fb_disable_feed', 1); add_action('do_feed_rdf', 'fb_disable_feed', 1); add_action('do_feed_rss', 'fb_disable_feed', 1); add_action('do_feed_rss2', 'fb_disable_feed', 1); add_action('do_feed_atom', 'fb_disable_feed', 1); remove_action( 'wp_head', 'feed_links_extra', 3 ); remove_action( 'wp_head', 'feed_links', 2 ); remove_action( 'wp_head', 'rsd_link' ); if ( ! function_exists( 'example_setup' ) ) : function mythemename_theme_setup() { // добавление миниатюры поста add_theme_support( 'post-thumbnails' ); // какие форматы постов будут поддерживаться add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'status', ) ); } endif; add_action( 'after_setup_theme', 'mythemename_theme_setup' ); /*============================================= BREADCRUMBS =============================================*/ // to include in functions.php function the_breadcrumb() { $showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show $delimiter = '»'; // delimiter between crumbs $home = 'Главная'; // text for the 'Home' link $showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show $before = ''; // tag before the current crumb $after = ''; // tag after the current crumb global $post; $homeLink = get_bloginfo('url'); if (is_front_page()) { } elseif (is_home()) { echo '